package in.muton.panels.paginator.components.badges;

import in.muton.edushare.pages.EduShareBasePage;
import in.muton.edushare.pages.common.EdusharePanel;
import in.muton.edushare.pages.curricula.CurriculaSummary;
import in.muton.edushare.pages.deptpages.DeptPage;
import in.muton.edushare.pages.univ.UnivPage;
import in.muton.edushare.url.EntityPageParams;
import in.muton.edushare.wicket.models.CayenneModel;
import in.muton.panels.paginator.badgehelpers.course.BatchBadgeInterface;
import in.muton.panels.paginator.helpers.deletelinks.BatchDelete;
import in.muton.panels.paginator.helpers.links.BatchNameLink;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.CSSPackageResource;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.model.IModel;

import com.edushare.common.vo.Batches;
import com.edushare.common.vo.Curricula;
import com.edushare.common.vo.Departments;
import com.edushare.common.vo.Universities;

public class BatchBadge extends EdusharePanel {
	private static final long serialVersionUID = 355189934925787807L;

	public BatchBadge(String id, EduShareBasePage page, IModel<Batches> model,
			BatchBadgeInterface bif) {
		super(id, model, page);
		this.page = page;
		add(CSSPackageResource.getHeaderContribution(CurriculaBadge.class,
				"badge.css"));
		batchModel = model;
		
		add(new BatchNameLink("nameLink", model, "name"));

		Curricula c = batchModel.getObject().getCurricula();
		PageParameters params = new PageParameters();
		params.put("0", c.getCurriculaId().toString());
		add(new BookmarkablePageLink<Void>("univ", UnivPage.class,
				EntityPageParams.getParams(new CayenneModel<Universities>(c
						.getUniversity()))));
		add(new BookmarkablePageLink<Void>("dept", DeptPage.class,
				EntityPageParams.getParams(new CayenneModel<Departments>(c
						.getDepartment()))));
		add(new BookmarkablePageLink<Void>("curr", CurriculaSummary.class,
				params));
		add(new BatchDelete("deleteLink", bif, batchModel ,this));
	}

	EduShareBasePage page = null;
	private IModel<Batches> batchModel;
}
